package example.lap4_p01_basicviewdemo;

import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;
import android.os.Build;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.formdangky);

//   EditText txtAcc = (EditText) findViewById(R.id.txtAcc);
//    String acc = txtAcc.getText().toString();
//    
//    CheckBox checkBox1 = (CheckBox) findViewById(R.id.checkBox1);
//    boolean chkBox1 = checkBox1.isChecked();
//    checkBox1.setOnClickListener(new View.OnClickListener() {
//		
//		@Override
//		public void onClick(View v) {
//			// TODO Auto-generated method stub
//		CheckBox c = (CheckBox)v;
//		if(c.isChecked()){
//			Toast.makeText(getBaseContext(), "Da chon CheckBox1", duration)
//			
//		}
//		}
//	});
    }
    public void submit(View v){
    	EditText txtTaiKhoan = (EditText) findViewById(R.id.txtTaiKhoan);
    	String taiKhoan = txtTaiKhoan.getText().toString();
    	EditText txtMatkhau = (EditText) findViewById(R.id.txtMatKhau);
    	String matKhau = txtMatkhau.getText().toString();
    	EditText txtXacNhanMatKhau = (EditText) findViewById(R.id.txtNhacLaiMatKhau);
    	String xacNhanMatKau = txtXacNhanMatKhau.getText().toString();
    	if(!matKhau.equals(xacNhanMatKau)){
    		Toast.makeText(getBaseContext(), "Xac nhan mat khau sai", Toast.LENGTH_SHORT).show();
    		txtMatkhau.setText("");
    		txtXacNhanMatKhau.setText("");
    		txtMatkhau.requestFocus();
    		return;
    		
    	}
    	EditText txtMail = (EditText) findViewById(R.id.txtEmail);
    	String email = txtMail.getText().toString();
    	RadioButton rdNam = (RadioButton) findViewById(R.id.rdNam);
    	String gioiTinh ="Nam";
    	if(rdNam.isChecked() == false){
    		gioiTinh ="Nu";
    		
    	}
    	String thongTinDangKy = "Tai Khoan"+taiKhoan+"\n"
    			+"Mat Khau" + matKhau+"\n"
    			+"Email" + email +"\n"
    			+"Gioi Tinh" + gioiTinh;
    	Toast.makeText(getBaseContext(),thongTinDangKy, Toast.LENGTH_SHORT).show();

    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

   
}
